#include "Board.h"

Board::Board(): m_width(8), m_height(8)
{
	//m_rules = new BreakthroughRules();
}

Board::Board(int width, int height)
{
	m_width = width;
	m_height = height;
}


Board::~Board()
{

}

void Board::initialize()
{
	m_grid.resize(m_width);

	// Set the size of the board
	for (int i = 0; i < m_height; ++i)
	{
		m_grid[i].resize(m_height);
	}

	// Populate the board.
	for (int col = 0; col < m_width; ++col)
	{
		for (int row = 0; row < m_height; ++row)
		{
			m_grid[col][row] = '.';
		}
	}
}

int Board::getWidth()
{
	return m_width;
}

int Board::getHeight()
{
	return m_height;
}

std::vector< std::vector<char> >& Board::getGrid()
{
	return m_grid;
}

void Board::output()
{
	std::cout << '\n' << "  ";
	for (int i = 0; i<m_width;i++)
		std::cout << i;
	std::cout << '\n' << "  ";
	for (int i = 0; i<m_width;i++)
		std::cout << "-";
	std::cout << "\n";
	for (unsigned int row = 0; row < m_grid.size(); ++row)
	{
		std::cout << row << "|";
		for (unsigned int col = 0; col < m_grid.size(); ++col)
		{
			std::cout << m_grid[row][col];
		}
		std::cout << "|";
		std::cout << '\n';
	}
	std::cout << "  ";
	for (int i = 0; i<m_width;i++)
		std::cout << "-";
	std::cout << '\n';
}

Board& Board::operator=(const Board& other)  {
	if (this != &other)
	{
		m_width = other.m_width;
		m_height = other.m_height;
		m_grid = other.m_grid;
	}
	return *this;
}